package com.topdt.jbpm.web.servlet.view;

import java.util.Comparator;
import java.util.Date;

public class HistTodoViewComparator  implements Comparator<HistTodoView>{

	public int compare(HistTodoView obj1, HistTodoView obj2) {
		int arriveFlag = obj1.getArriveTime().compareTo(obj2.getArriveTime());
		if(arriveFlag!=0){
			return arriveFlag;
		}else{
			if(obj1.getBatch()<obj2.getBatch()){
				return -1;
			}else if(obj1.getBatch()>obj2.getBatch()){
				return 1;
			}else{
				Date finishTime1 =obj1.getFinishTime();
				Date finishTime2 =obj2.getFinishTime();
				if(finishTime1 ==null){
					finishTime1 = new Date();
				}
				if(finishTime2 ==null){
					finishTime2 = new Date();
				}
				return finishTime1.compareTo(finishTime2);
			}
		}
	}



}
